package valuetransfer;

/**
 * @author shkstart
 * @date 2022/4/25 - 21:31
 */

/*  笔记：有static的方法就得创造对象来调用类中得属性方法，没有static的方法就不用，
* */
public class ValueTransferTest02 {
    public static void main(String[] args) {
        Data data = new Data();
        data.m = 10;
        data.n = 20;

        System.out.println("m = " + data.m + ", n = " + data.n);

        //交换m和n的值
//        int temp = data.m;
//        data.m = data.n;
//        data.n = temp;
        ValueTransferTest02 test = new ValueTransferTest02();

        test.swap(data);



    }
    public void swap(Data data) {
        int temp = data.m;
        data.m = data.n;
        data.n = temp;
    }
    static class Data {
        int m;
        int n;
    }
}
